package com.goods.business.converter;

import com.goods.common.model.business.ProductCategory;
import com.goods.common.vo.business.ProductCategoryVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class CategoryConverter {

    /**
     * 转vo
     */
    public static ProductCategoryVO converterToProductCategoryVO(ProductCategory productCategory){
        ProductCategoryVO productCategoryVO = new ProductCategoryVO();
        BeanUtils.copyProperties(productCategory,productCategoryVO);
        return productCategoryVO;
    }

    /**
     * 转成productCategoryVOList
     */
    public static List<ProductCategoryVO> converterToProductCategoryVOList(List<ProductCategory> productCategoryList){
        List<ProductCategoryVO> productCategoryVOList = new ArrayList<>();
        if(!CollectionUtils.isEmpty(productCategoryList)){
            for (ProductCategory productCategory : productCategoryList) {
                ProductCategoryVO categoryVO = converterToProductCategoryVO(productCategory);
                productCategoryVOList.add(categoryVO);
            }
        }
        return productCategoryVOList;
    }
}
